
package com.qf.service.impl;

import java.util.List;

import com.qf.dao.impl.ContactDaoImpl;
import com.qf.model.Contact;
import com.qf.service.ContactService;

public class ContactServiceImpl implements ContactService{
	private ContactDaoImpl contactDaoImpl=new ContactDaoImpl();
	@Override
	public boolean addContact(Object[] params) {
		String sql="insert into contact values(null,?,?,?,?,?,?);";
		return contactDaoImpl.addContact(sql,params);
	}
	@Override
	public Contact findContact(Object[] params) {
		String sql="select * from contact where cid=? and uid=?";
		//TODO
		return contactDaoImpl.findContact(sql,params);
			
	}
	public boolean upContact(Object[] params) {
		String sql="update contact set cname=?,ctel=?,caddress=?,cremark=?,tid=? where cid=?";
		return contactDaoImpl.upContact(sql,params);
			
	}

	@Override
	public List<Contact> findContacts(String condition, int uid) {
		condition="%"+condition+"%";
		String sql="select * from contact where cname=? or uid =? or ctel=?";
		Object[] params={condition,uid,condition};
		//TODO
		return contactDaoImpl.findContacts(sql, params);
			
	}


}

	